import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-star',
  templateUrl: './star.component.html',
  styleUrls: ['./star.component.css']
})
export class StarComponent implements OnInit {
  @Input()
  rating: number;
  stars: Array<Boolean>;
  constructor() { }

  ngOnInit() {
    this.stars = [];
    for (let i = 0; i < 5; i++) {
      if ( i < this.rating ) {
        this.stars[i] = false;
      } else {
        this.stars[i] = true;
      }
    }
  }

}
